package file;

import java.io.File;

public class Test04 {
    public static void main(String[] args)
    {
        File f=new File("C:/");    //建立File变量,并设定由f变量变数引用
        System.out.println("文件名称\t\t文件类型\t\t文件大小");
        System.out.println("===================================================");
        String fileList[]=f.list();    //调用不带参数的list()方法
        for (int i=0;i<fileList.length;i++)
        {    //遍历返回的字符数组
            System.out.print(fileList[i]+"\t\t");
            System.out.print((new File("C:/",fileList[i])).isFile()?"文件"+ "\t\t":"文件夹"+"\t\t");
            System.out.println((new File("C:/",fileList[i])).length()+"字节");
        }
    }
}
